<template>
  <div>
    <ul class="mui-table-view">
      <li class="mui-table-view-cell mui-media" v-for="item in list" :key="item.id">
        <router-link :to="'/home/newsInfo/' + item.id">
          <img class="mui-media-object mui-pull-left" :src="item.url">
          <div class="mui-media-body">
            <h3>{{ item.title }}</h3>
            <p class="mui-ellipsis">
              <span>{{ item.pinglun }}</span>
              <span @click="click(item.id)">点击 {{ item.click }} 次</span>
            </p>
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>

<style lang="less" scoped>

   .mui-ellipsis{
       font-size: 16px;
       color: #26aff2;

    //    设置两边对齐
       display: flex;
       justify-content: space-between;
   }
</style>
<script>
export default {
    data:function(){
        return {
            list:null
        }
    },
    created(){
        this.getList()
    },
    methods:{
        getList:function(){
            this.$http.jsonp('http://localhost:5000/getNewsList').then(res => {
              // console.log(res)
                this.list = res.body
            })
        },
        click:function (id) { 
           this.$http.jsonp('http://localhost:5000/click?id='+id).then(res => {
              // console.log(res.body)
                console.log(1111)
                if(res.body.success == 0) {
                console.log(11)
                this.getList()
                }
            })
         }
    }
}
</script>